<template>
	<view class="content poRel">
		<scroll-view style="height: calc(100vh);" class="wid100" scroll-y="true" @scrolltolower="lower">
			<view class="hei20"></view>
			<wsj v-if="list.length == 0" zs='0'></wsj>
			<block v-for="(item,index) in list" :key="index">
				<view class="mar-top30 wid90 mar dis disAl">
					<view style="height: 74rpx;width: 15%;">
						<image :src="item.user.avatar" class="hei100 borRad50" style="width: 74rpx;"></image>
					</view>
					<view class="wid85 dis disAl disJuB">
						<view>
							<view class="fowe600 foSi30 liH40">{{item.user.nickname}}</view>
							<view class="mar-top10 foSi20" style="color: #737373;">拉黑时间：{{item.end_service}}</view>
						</view>
						<view class="dis disAl disJuC foSi20 butt1 borRad10" @click="yichu(index)"
						:style="'border: 1rpx solid '+theme.main_color+';color: '+theme.main_color+';'">移除</view>
					</view>
				</view>
			</block>
			<view style="height: 50rpx;"></view>
		</scroll-view>
	</view>
</template>

<script>
	import wsj from '../common/w_sj.vue'
	export default {
		components: {
			wsj
		},
		data() {
			return {
				url: this.global.url,
				last_page: 0,
				page: 1,
				list: [],
				theme: null
			}
		},
		onLoad() {
			this.theme = uni.getStorageSync('theme')
			this.getList()
		},
		methods: {
			yichu(index){
				var that = this;
				uni.request({
					url: that.global.url + 'api/qianyu_smfw/usershieid/user_del',
					method: "POST",
					header: {
						'site-id': that.global.site_id, //自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {
						id: that.list[index].id,
						tech_id:uni.getStorageSync('tech_id')
					},
					success(res) {
						let result = res.data
						if (result.code == 1) {
							that.list.splice(index, 1);
						}else{
							uni.showToast({
								title: result.msg,
								//将值设置为 success 或者直接不用写icon这个参数
								icon: 'error',
								//显示持续时间为 2秒
								duration: 2000
							}) 
						}
					}
				})
				
			},
			lower(e) {
				if(this.last_page > this.page){
					this.page++
					this.getList()
				}
			},
			getList(){
				var that = this;
				uni.request({
					url: that.global.url + 'api/qianyu_smfw/usershieid/user_lists',
					method: "POST",
					header: {
						'site-id': that.global.site_id, //自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {
						tech_id:uni.getStorageSync('tech_id')
					},
					success(res) {
						let result = res.data
						console.log(result);
						if (result.code == 1) {
							that.list = result.data
						}else{
							uni.showToast({
								title: result.msg,
								//将值设置为 success 或者直接不用写icon这个参数
								icon: 'error',
								//显示持续时间为 2秒
								duration: 2000
							}) 
						}
					}
				})
				
			},
			tiaozhuan(url) {
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style>
	.content {
		min-height: 100vh;
	}
	.xia{
		height: 1rpx;
		background-color: #E5E5E5;
	}
	.butt1{
		width: 90rpx;
		height: 44rpx;
	}
</style>